var comment = new vo.newObj({
	el:'#comment',
	datas:{
		content:'来留下自己的足迹吧!',
		articleId:id,
		parentId:'',
	},
	methods:{
		enter:function(datas,obj){
			if(typeof(obj) == 'undefined'){
				obj = this.el;
			}
			if(getElementsByAttr_r(obj, "name", "content")[0].value == '来留下自己的足迹吧!'){
				this.modify("content","");
			}
		},
		blur:function(datas,obj){
			if(typeof(obj) == 'undefined'){
				obj = this.el;
			}
			if(getElementsByAttr_r(obj, "name", "content")[0].value == ''){
				this.modify("content",'来留下自己的足迹吧!');
			}
		},
		send:function(datas,obj){
			if(typeof(obj) == 'undefined'){
				obj = this.el;
			}
			var text = getElementsByAttr_r(obj, "name", "content")[0];
			var content = text.value;
			content = content.replace(/\s+/g,"");
			var wind = getElementsByAttr_r(obj,"class","wind")[0];
			var warn = getElementsByAttr_r(wind, "class", "warn")[0];
			if(content == '来留下自己的足迹吧!' || content == ""){
				if(wind.style.display == "none"||wind.style.display == ""){
					wind.style.display="block";
					warn.innerHTML = "评论不能为空";
					warn.setAttribute("class","warn warn-error");
					timeout(wind,warn);
				}
			}else{
				content = content.replace(/\"/g,"'");
				var uid = obj.getAttribute("uid");
				if(uid != null){
					this.modify("parentId",uid);
				}else{
					this.modify("parentId",null);
				}
				this.modify("content",content);
				obj.disabled="true";
				ajax({
					method:'POST',
					url:'/article/comment',
					datas:datas,
					success:function(resp){
						if(resp.status == "200"){
							commentList.methods.flush();
							comment.modify("content","");
							wind.style.display="block";
							warn.innerHTML = "发表评论成功";
							warn.setAttribute("class","warn warn-ok");
							timeout(wind,warn);
						}else{
							comment.modify("content","");
							wind.style.display="block";
							warn.innerHTML = resp.status+":"+resp.datas;
							warn.setAttribute("class","warn warn-error");
							timeout(wind,warn);
						}
						obj.disabled="false";
					},
					error:function(){
						wind.style.display="block";
						warn.innerHTML = "发表评论失败";
						warn.setAttribute("class","warn warn-error");
						timeout(wind,warn);
					}
				});
			}
		},
		toggle:function(datas,obj){
			if(typeof(obj) == 'undefined'){
				obj = this.el;
			}
			var emoji = getElementsByAttr_r(obj, "class", "emoji-wind")[0];
			if(emoji.style.display == "block"){
				emoji.style.display = "none";
			}else{
				emoji.style.display = "block";
			}
		},
		emoji:function(datas,obj,t){
			if(typeof(obj) == 'undefined'){
				obj = this.el;
			}
			if(typeof(t) == 'undefined'){
				t = target();
			}
			var html = t.innerHTML;
			var content = getElementsByAttr_r(obj, "name", "content")[0];
			if(content == "来留下自己的足迹吧!"){
				content.value = "";
			}
			content.value+=html;
		}
	}
});
function timeout(wind,warn){
	setTimeout(function(){
		wind.style.display = "none";
		warn.innerHTML = "";
		warn.setAttribute("class","warn");
	}, 1700);
}